<template>
  <div>
    <button @click="flag = !flag">Toggle</button>
    <Transition name="fade">
      <p class="custom-tras" v-if="flag">Hello Liu Longbin.</p>
    </Transition>

    <hr />

    <button @click="flag2 = !flag2">Toggle2</button>
    <Transition name="custom">
      <div class="box" v-if="flag2"></div>
    </Transition>
  </div>
</template>

<script setup>
import { ref } from 'vue'
const flag = ref(false)
const flag2 = ref(false)
</script>

<style scoped>
.custom-tras {
  opacity: 0.5;
  font-size: 50px;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
  font-size: 12px;
}

.fade-enter-to,
.fade-leave-from {
  opacity: 0.5;
  font-size: 50px;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 1s ease, font-size 1s ease;
}

/*----------*/

.box {
  width: 150px;
  height: 150px;
  background-color: red;
  margin-top: 10px;
  border-radius: 50%;
}

.custom-enter-from,
.custom-leave-to {
  width: 0;
  height: 0;
  border-radius: 0;
}

.custom-enter-to,
.custom-leave-from {
  width: 150px;
  height: 150px;
  border-radius: 50%;
}

.custom-enter-active,
.custom-leave-active {
  transition: width 1s ease, height 1s ease, border-radius 1s ease;
}
</style>
